home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_perl.idb / usr / freeware / catman / p_man / cat3 / B::CC.Z / B::CC
Encoding:
Text File  |  1998-10-28  |  8.8 KB  |  265 lines

  1.  
  2.  
  3.  
  4.      BBBB::::::::CCCCCCCC((((3333))))         22223333////JJJJuuuullll////99998888 ((((ppppeeeerrrrllll 5555....000000005555,,,, ppppaaaattttcccchhhh 00002222))))          BBBB::::::::CCCCCCCC((((3333))))
  5.  
  6.  
  7.  
  8.      NNNNAAAAMMMMEEEE
  9.       B::CC    - Perl compiler's optimized C translation backend
  10.  
  11.      SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  12.           perl -MO=CC[,OPTIONS]    foo.pl
  13.  
  14.  
  15.      DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  16.       This compiler    backend    takes Perl source and generates    C
  17.       source code corresponding to the flow    of your    program. In
  18.       other    words, this backend is somewhat    a "real" compiler in
  19.       the sense that many people think about compilers. Note
  20.       however that,    currently, it is a very    poor compiler in that
  21.       although it generates    (mostly, or at least sometimes)
  22.       correct code,    it performs relatively few optimisations.
  23.       This will change as the compiler develops. The result    is
  24.       that running an executable compiled with this    backend    may
  25.       start    up more    quickly    than running the original Perl program
  26.       (a feature shared by the CCCC compiler backend--see _B::_C) and
  27.       may also execute slightly faster. This is by no means    a good
  28.       optimising compiler--yet.
  29.  
  30.      OOOOPPPPTTTTIIIIOOOONNNNSSSS
  31.       If there are any non-option arguments, they are taken    to be
  32.       names    of objects to be saved (probably doesn't work properly
  33.       yet).     Without extra arguments, it saves the main program.
  34.  
  35.       ----ooooffffiiiilllleeeennnnaaaammmmeeee
  36.           Output to    filename instead of STDOUT
  37.  
  38.       ----vvvv  Verbose compilation (currently gives a few compilation
  39.           statistics).
  40.  
  41.       --------  Force end    of options
  42.  
  43.       ----uuuuPPPPaaaacccckkkknnnnaaaammmmeeee
  44.           Force apparently unused subs from    package    Packname to be
  45.           compiled.     This allows programs to use eval "_f_o_o()" even
  46.           when sub foo is never seen to be used at compile time.
  47.           The down side is that any    subs which really are never
  48.           used also    have code generated. This option is necessary,
  49.           for example, if you have a signal    handler    foo which you
  50.           initialise with $SIG{BAR}    = "foo".  A better fix,
  51.           though, is just to change    it to $SIG{BAR}    = \&foo. You
  52.           can have multiple    ----uuuu options. The    compiler tries to
  53.           figure out which packages    may possibly have subs in
  54.           which need compiling but the current version doesn't do
  55.           it very well. In particular, it is confused by nested
  56.           packages (i.e.  of the form A::B)    where package A    does
  57.           not contain any subs.
  58.  
  59.  
  60.  
  61.  
  62.  
  63.      Page 1                        (printed 10/23/98)
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.      BBBB::::::::CCCCCCCC((((3333))))         22223333////JJJJuuuullll////99998888 ((((ppppeeeerrrrllll 5555....000000005555,,,, ppppaaaattttcccchhhh 00002222))))          BBBB::::::::CCCCCCCC((((3333))))
  71.  
  72.  
  73.  
  74.       ----mmmmMMMMoooodddduuuulllleeeennnnaaaammmmeeee
  75.           Instead of generating source for a runnable executable,
  76.           generate source for an XSUB module. The boot_Modulename
  77.           function (which DynaLoader can look for) does the
  78.           appropriate initialisation and runs the main part    of the
  79.           Perl source that is being    compiled.
  80.  
  81.       ----DDDD  Debug options (concatenated or separate flags like perl
  82.           -D).
  83.  
  84.       ----DDDDrrrr Writes debugging output to STDERR    just as    it's about to
  85.           write to the program's runtime (otherwise    writes
  86.           debugging    info as    comments in its    C output).
  87.  
  88.       ----DDDDOOOO Outputs each OP as it's compiled
  89.  
  90.       ----DDDDssss Outputs the contents of the shadow stack at each OP
  91.  
  92.       ----DDDDpppp Outputs the contents of the shadow pad of    lexicals as
  93.           it's loaded for each sub or the main program.
  94.  
  95.       ----DDDDqqqq Outputs the name of each fake PP function    in the queue
  96.           as it's about to process it.
  97.  
  98.       ----DDDDllll Output the filename and line number of each original
  99.           line of Perl code    as it's    processed (pp_nextstate).
  100.  
  101.       ----DDDDtttt Outputs timing information of compilation    stages.
  102.  
  103.       ----ffff  Force optimisations on or    off one    at a time.
  104.  
  105.       ----ffffffffrrrreeeeeeeettttmmmmppppssss----eeeeaaaacccchhhh----bbbbbbbblllloooocccckkkk
  106.           Delays FREETMPS from the end of each statement to    the
  107.           end of the each basic block.
  108.  
  109.       ----ffffffffrrrreeeeeeeettttmmmmppppssss----eeeeaaaacccchhhh----lllloooooooopppp
  110.           Delays FREETMPS from the end of each statement to    the
  111.           end of the group of basic    blocks forming a loop. At most
  112.           one of the freetmps-each-* options can be    used.
  113.  
  114.       ----ffffoooommmmiiiitttt----ttttaaaaiiiinnnntttt
  115.           Omits generating code for    handling perl's    tainting
  116.           mechanism.
  117.  
  118.       ----OOOOnnnn Optimisation level (n = 0, 1, 2, ...). ----OOOO    means ----OOOO1111.
  119.           Currently, ----OOOO1111 sets ----ffffffffrrrreeeeeeeettttmmmmppppssss----eeeeaaaacccchhhh----bbbbbbbblllloooocccckkkk and ----OOOO2222 sets
  120.           ----ffffffffrrrreeeeeeeettttmmmmppppssss----eeeeaaaacccchhhh----lllloooooooopppp.
  121.  
  122.      EEEEXXXXAAAAMMMMPPPPLLLLEEEESSSS
  123.           perl -MO=CC,-O2,-ofoo.c foo.pl
  124.           perl cc_harness -o foo foo.c
  125.  
  126.  
  127.  
  128.  
  129.      Page 2                        (printed 10/23/98)
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.      BBBB::::::::CCCCCCCC((((3333))))         22223333////JJJJuuuullll////99998888 ((((ppppeeeerrrrllll 5555....000000005555,,,, ppppaaaattttcccchhhh 00002222))))          BBBB::::::::CCCCCCCC((((3333))))
  137.  
  138.  
  139.  
  140.       Note that cc_harness lives in    the B subdirectory of your
  141.       perl library directory. The utility called perlcc may    also
  142.       be used to help make use of this compiler.
  143.  
  144.           perl -MO=CC,-mFoo,-oFoo.c Foo.pm
  145.           perl cc_harness -shared -c -o    Foo.so Foo.c
  146.  
  147.  
  148.      BBBBUUUUGGGGSSSS
  149.       Plenty. Current status: experimental.
  150.  
  151.      DDDDIIIIFFFFFFFFEEEERRRREEEENNNNCCCCEEEESSSS
  152.       These    aren't really bugs but they are    constructs which are
  153.       heavily tied to perl's compile-and-go    implementation and
  154.       with which this compiler backend cannot cope.
  155.  
  156.       LLLLooooooooppppssss
  157.  
  158.       Standard perl    calculates the target of "next", "last", and
  159.       "redo" at run-time. The compiler calculates the targets at
  160.       compile-time.     For example, the program
  161.  
  162.           sub skip_on_odd {    next NUMBER if $_[0] % 2 }
  163.           NUMBER: for ($i =    0; $i <    5; $i++) {
  164.           skip_on_odd($i);
  165.           print    $i;
  166.           }
  167.  
  168.       produces the output
  169.  
  170.           024
  171.  
  172.       with standard    perl but gives a compile-time error with the
  173.       compiler.
  174.  
  175.       CCCCoooonnnntttteeeexxxxtttt ooooffff """"........""""
  176.  
  177.       The context (scalar or array)    of the ".." operator
  178.       determines whether it    behaves    as a range or a    flip/flop.
  179.       Standard perl    delays until runtime the decision of which
  180.       context it is    in but the compiler needs to know the context
  181.       at compile-time. For example,
  182.  
  183.           @a = (4,6,1,0,0,1);
  184.           sub range    { (shift @a)..(shift @a) }
  185.           print range();
  186.           while (@a) { print scalar(range()) }
  187.  
  188.       generates the    output
  189.  
  190.           456123E0
  191.  
  192.  
  193.  
  194.  
  195.      Page 3                        (printed 10/23/98)
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.      BBBB::::::::CCCCCCCC((((3333))))         22223333////JJJJuuuullll////99998888 ((((ppppeeeerrrrllll 5555....000000005555,,,, ppppaaaattttcccchhhh 00002222))))          BBBB::::::::CCCCCCCC((((3333))))
  203.  
  204.  
  205.  
  206.       with standard    Perl but gives a compile-time error with
  207.       compiled Perl.
  208.  
  209.       AAAArrrriiiitttthhhhmmmmeeeettttiiiicccc
  210.  
  211.       Compiled Perl    programs use native C arithemtic much more
  212.       frequently than standard perl. Operations on large numbers
  213.       or on    boundary cases may produce different behaviour.
  214.  
  215.       DDDDeeeepppprrrreeeeccccaaaatttteeeedddd ffffeeeeaaaattttuuuurrrreeeessss
  216.  
  217.       Features of standard perl such as $[ which have been
  218.       deprecated in    standard perl since Perl5 was released have
  219.       not been implemented in the compiler.
  220.  
  221.      AAAAUUUUTTTTHHHHOOOORRRR
  222.       Malcolm Beattie, mbeattie@sable.ox.ac.uk
  223.  
  224.  
  225.  
  226.  
  227.  
  228.  
  229.  
  230.  
  231.  
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.      Page 4                        (printed 10/23/98)
  262.  
  263.  
  264.  
  265.